#!/usr/bin/env python

def CodingOverhead(g,q):

	oh=0
	for r in range(0,g):
		oh+=1./(q**(g-r)-1)

	return oh
	

if __name__ == '__main__':

	print CodingOverhead(2,2)
	print CodingOverhead(4,2)
	print CodingOverhead(8,2)
	print CodingOverhead(16,2)
	print CodingOverhead(32,2)

	print '\n'

	print CodingOverhead(2,2**8)
	print CodingOverhead(4,2**8)
	print CodingOverhead(8,2**8)
	print CodingOverhead(16,2**8)
	print CodingOverhead(32,2**8)

	print '\n'

	print CodingOverhead(2,2**16)
	print CodingOverhead(4,2**16)
	print CodingOverhead(8,2**16)
	print CodingOverhead(16,2**16)
	print CodingOverhead(32,2**16)

	print '\n'

#	print CodingOverhead(8,2)
#	print CodingOverhead(16,2)
#	print CodingOverhead(32,2)
#	print CodingOverhead(64,2)
#	print CodingOverhead(128,2)

#	print '\n'

#	print CodingOverhead(8,2**8)
#	print CodingOverhead(16,2**8)
#	print CodingOverhead(32,2**8)
#	print CodingOverhead(64,2**8)
#	print CodingOverhead(128,2**8)

#	print '\n'

#	print CodingOverhead(8,2**16)
#	print CodingOverhead(16,2**16)
#	print CodingOverhead(32,2**16)
#	print CodingOverhead(64,2**16)
#	print CodingOverhead(128,2**16)

#	print '\n'



